<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2021/11/10
 * Time: 10:42
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

declare(strict_types=1);

namespace app\admin\controller;

use app\common\lib\Show;
use app\common\lib\Status;
use think\App;
use app\common\business\System as BusObj;
use think\Exception;
use think\facade\Cache;

class System extends Base
{
    protected BusObj $busObj;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->busObj = new BusObj();
    }
    public function clear(){
        Cache::clear();
        return Show::json_show(1,"服务器缓存清理完成");
    }

    /**
     * @return \think\response\Json
     * @throws Exception
     */
    public function save1()
    {
        $data = $this->request->param();
        if (empty($data['backgroundColor']) || empty($data['color']) || empty($data['selectedColor']) || empty($data['h_backgroundColor']) || empty($data['h_color']) || empty($data['h_selectedColor']) || empty($data['page_bg']) || empty($data['goupiao']) || empty($data['jieshao']) || empty($data['shop']) || empty($data['yy'])) {
            return Show::json_show(0,"请填写完整");
        }
        $row  =$this->busObj->getBaseById(2);
        if(empty($row)){
            return Show::json_show(0,'数据不存在');
        }
        $data['update_time'] = time();

         $res = $this->busObj->updateByData($row['id'],$data);
        if ($res) {
            Cache::clear();
            return Show::json_show(1,"成功");
        }else{
            return Show::json_show(0, '失败');
        }
    }

}